#include <iostream>
using namespace std;

int b = 0;
int n = 0;
int arr[51] = { 0 };

bool fun()
{
    for (int i = 0; i < n; i++)
    {
        if (b % arr[i])
        {
            return false;
        }
        int x = b / arr[i];
        if (x & (x - 1))
        {
            return false;
        }
    }
    return true;
}


int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        b = max(b, arr[i]);
    }
    if (fun())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

int main() {
    string str1;
    string str2;
    cin >> str1 >> str2;
    int n1 = str1.size();
    int n2 = str2.size();
    int my_min = 60;
    for (int i = 0; i <= n2 - n1; i++)
    {
        int tmp = 0;
        for (int j = 0; j < n1; j++)
        {
            if (str1[j] != str2[i + j])
            {
                tmp++;
            }
        }
        my_min = min(my_min, tmp);
    }
    cout << my_min << endl;
    return 0;
}

const int N = 31;
const int M = 20001;

int arr[N];
int dp[N][M];
int main() {
    int v, n;
    cin >> v >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= v; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= arr[i])
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - arr[i]] + arr[i]);
            }
        }
    }
    cout << (v - dp[n][v]) << endl;
    return 0;
}